// 模拟用户数据库
const users = [
  { id: 1, username: 'admin', password: '123', role: 'admin' },
  { id: 2, username: 'user', password: '456', role: 'user' }
];

// 通过用户名查找用户
const findByUsername = (username) => {
  return users.find(user => user.username === username);
};

// 验证用户名和密码
const validateUser = (username, password) => {
  const user = findByUsername(username);
  if (!user || user.password !== password) return null;
  return user;
};

module.exports = {
  users,
  findByUsername,
  validateUser
};